// 引包
const mongoose = require('mongoose')
// 连接数据库
mongoose.connect('mongodb://localhost/myfirst')

// 获取表
let Schema = mongoose.Schema;

// 规定表结构
let studentSchema = new Schema({
  name: {
    type: String,
    required: true
  },
  gender: {
    type: Number,
    enum: [0, 1],
    default: 0
  },
  age: {
    type: Number
  },
  hobbies: {
    type: String
  }
})

// 创建student模型
module.exports = mongoose.model('Student', studentSchema)